<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>{$siteInfo['title']}-{$siteInfo['subtitle']}</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp"/>
  <link rel="stylesheet" href="/themes/amaze/assets/css/amazeui.min.css">
</head>
<body>
{include file="common/header" /}
<!--轮播图-->
<div data-am-widget="slider" class="am-slider am-slider-c1" data-am-slider='{"directionNav":false}' >
  <ul class="am-slides">
    {volist name="carousel" id="vo"}
    <li>
      <a href="{:url('/p/'.$vo.id)}"><img style="height:200px;" src="{$vo.cover_image|default='/uploads/default/default_cover.jpg'}"></a>
      <div class="am-slider-desc">{$vo.title}</div>
    </li>
    {/volist}
  </ul>
</div>

<!--置顶推荐-->
<div data-am-widget="titlebar" class="am-titlebar am-titlebar-multi" >
  <h2 class="am-titlebar-title ">置顶推荐</h2>
</div>
<ul data-am-widget="gallery" class="am-gallery am-avg-sm-2  am-avg-md-3 am-avg-lg-4 am-gallery-overlay" data-am-gallery="{ pureview: true }" >
  {volist name="topArticle" id="vo"}
  <li>
    <div class="am-gallery-item">
      <a href="{:url('/p/'.$vo.id)}" >
        <img style="height:100px" src="{$vo.cover_image|default='/uploads/default/default_cover.jpg'}"  alt="{$vo.title}"/>
        <h3 class="am-gallery-title">{$vo.title}</h3>
      </a>
    </div>
  </li>
  {/volist}
</ul>

<!--内容列表-->
<div data-am-widget="titlebar" class="am-titlebar am-titlebar-multi" >
  <h2 class="am-titlebar-title ">最新文章</h2>
</div>
<div data-am-widget="list_news" class="am-list-news am-list-news-default" >
  <div class="am-list-news-bd">
    <ul class="am-list" id="new-list"></ul>
  </div>
</div>
<button id="load-new" type="button" class="am-btn am-btn-secondary am-btn-block">加载更多</button>
{include file="common/footer" /}
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="/themes/amaze/assets/js/amazeui.min.js"></script>
<script src="/themes/amaze/assets/js/common.js"></script>
<script>
  var page = 1;
  loadNews(page);
  $("#load-new").click(function () {
    page = page +1;
    loadNews(page)
  })
  function loadNews(page) {
    $.ajax({
      type: "POST",
      url: "/home/post/newList",
      data: {
        page: page
      },
      success: function (e) {
        if (e.data == ""){
          $("#load-new").text("没有更多了")
          $("#load-new").css({"background":"#999","border":"0px"})
          $("load-new").addClass("am-disabled");
        }

        $.each(e.data, function (index, item) {

          var createTime = getMyDate(item.create_time);
          if (item.cover_image == "") {
            item.cover_image = '/uploads/default/default_cover.jpg';
          }

          if (item.content == null || item.content == ""){
            var introduce = "";
          }else {
            var introduce = delHtmlTag(item.content).substr(0, 60)
          }

          $("#new-list").append('<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left"><div class="am-u-sm-4 am-list-thumb"><a href="/p/'+item.id+'"><img style="height:80px;" src="'+item.cover_image+'" /></a></div><div class=" am-u-sm-8 am-list-main"><h3 class="am-list-item-hd"><a href="/p/'+item.id+'">'+item.title+'</a></h3><div class="am-list-item-text">'+introduce+'</div></div></li>');
        })
      }
    })
  }

  function delHtmlTag(str){
    return str.replace(/<[^>]+>/g,"");//去掉所有的html标记
  }
</script>
</body>
</html>